package nii.game.mobileserio.enemy;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

import android.content.Context;

public class Mushroom {
	
	// DECLARATIONS ===========================================
	private BitmapTextureAtlas mushroom_BitmapTextureAtlas;
	private TiledTextureRegion mushroom_TiledTextureRegion;
	private AnimatedSprite mushroom_AnimatedSprite;

	private float positionX = 0;
	private float positionY = 0;
	
	// CONTRUCTOR ==============================================
	public Mushroom(){
		
	}
	
	//========================================|| onLoadResources ||===========================================//
	
	public void onLoadResources(Engine mEngine, Context mContext) {
		
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
		this.mushroom_BitmapTextureAtlas = new BitmapTextureAtlas(256, 64, TextureOptions.DEFAULT);
		this.mushroom_TiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mushroom_BitmapTextureAtlas, mContext,
						"mushroom.png", 0, 0, 3, 1);
		mEngine.getTextureManager().loadTexture(this.mushroom_BitmapTextureAtlas);

	}
	
	//==========================================|| onLoadScene ||=============================================//
	
	public void onLoadScene(Scene mScene) {

		mushroom_AnimatedSprite = new AnimatedSprite(this.positionX, this.positionY, this.mushroom_TiledTextureRegion.deepCopy());
		mushroom_AnimatedSprite.animate(new long[] {200}, new int[] {0}, 200);
		mushroom_AnimatedSprite.setCullingEnabled(true);
		mScene.attachChild(mushroom_AnimatedSprite);
	}
	
	// setPosition ================================================
	public void setPosition(float pX, float pY){
		positionX = pX;
		positionY = pY;
	}
	
	// AnimatedSprite getAnimatedSpritE ===========================
	public AnimatedSprite getAnimatedSprite(){
		return mushroom_AnimatedSprite;
	}
}
